import { Component, Input, OnInit,ContentChildren, QueryList} from '@angular/core';
import {BottomSheetConfig} from '@src/app/model/jack.model'
import {BottomSheetItemComponent} from './bottom-sheet-item.component'

@Component({
  selector: 'jack-bottom-sheet',
  templateUrl: './bottom-sheet.component.html',
  styleUrls: ['./bottom-sheet.component.css']
})
export class BottomSheetComponent implements OnInit {

  @Input() 
  conf: BottomSheetConfig;

  @ContentChildren(BottomSheetItemComponent)
  bottomsheetitems: QueryList<BottomSheetItemComponent>;


  ui:any = {
    show: false,
  }

  constructor() { }

  ngOnInit(): void {
  }

  ngAfterContentInit() {
    console.log(this.bottomsheetitems)

  }

  public open():void {
    this.ui.show = true;
  }

  public close():void {
    this.ui.show = false;
  }

  public onmaskclick():void {
    this.ui.show = false;
  }
  
  public onopen() {
    if(!this.conf) {
      return;
    }
    this.conf.onopen && this.conf.onopen();

  }
  public onclose() {
    if(!this.conf) {
      return;
    }
    this.conf.onclose && this.conf.onclose()
  }

}
